#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>


/**
 * Macros for data-struct type.
 */
#define dst_member(name,X) {X}name; const char * struct_name##_member = #X;
#define Data_struct(n,member) typedef struct _##n dst_member(n,member);

#define dst_member_str(name) struct_name##_member

/**
 * Data type size table.
 */
typedef struct tpsz {
	char    *s;
	size_t  type_size; 
} type_size_t; 

type_size_t type_size_tb[]= {
	{"char",          sizeof(char)},
	{"unsigned char", sizeof(unsigned char)},
	{"int",           sizeof(int)},
	{"long",          sizeof(long)},
	{"unsigned int",  sizeof(unsigned int)},
	{"unsigned long", sizeof(unsigned long)},
	{"float",         sizeof(float)},
	{"double",        sizeof(double)},
	{"uint8_t",       sizeof(uint8_t)},
	{"uint16_t",      sizeof(uint16_t)},
	{"uint32_t",      sizeof(uint32_t)},
	{"uint64_t",      sizeof(uint64_t)},
	{"int8_t",        sizeof(int8_t)},
	{"int16_t",       sizeof(int16_t)},
	{"int32_t",       sizeof(int32_t)},
	{"int64_t",       sizeof(int64_t)},
	{"ptr",           sizeof(int *)},	  // pointer size 
};

Data_struct(a,
	int   	a1;
	int   	a2;
	float 	a3;
	void * (*a4)(void);
);


// 不可嵌套
//Data_struct(b,
//	int         b1;
//	int         b2;
//	Data_struct (c, 
//	    int c1;
//	    int c2;
//	);
//	float       b3;
//);


int main ()
{
	a a0;
	struct _a a1;
	printf("a_members : \n %s\n", dst_member_str(a));
	
	return 0;
}

